-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
bugSomething isn't workingSomething isn't workingvNextBreaks binary compatibilityBreaks binary compatibility
Description
Describe the bug
Lines 761 to 763 in 7841cf8
conditional_t<disjunction_v<is_default_constructible<_Ty>, _Is_implicitly_default_constructible<_Ty>>, _Ty, | |
_Empty_array_element> | |
_Elems[1]{}; |
A std::array<T,0>
is meant to be an array of zero elements, but it's actually an array of one element as long as T
is default-constructible in this implementation. This is clearly non-compliant.
Command-line test case
C:\Temp>type repro.cpp
#include <array>
#include <iostream>
struct S { S() { std::cout << "test failure\n"; } };
int main() {
std::array<S,0> s;
}
C:\Temp>cl /EHsc /W4 /WX /std:c++latest .\repro.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.36.32522 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
/std:c++latest is provided as a preview of language features from the latest C++
working draft, and we're eager to hear about bugs and suggestions for improvements.
However, note that these features are provided as-is without support, and subject
to changes or removal as the working draft evolves. See
https://go.microsoft.com/fwlink/?linkid=2045807 for details.
repro.cpp
Microsoft (R) Incremental Linker Version 14.36.32522.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:repro.exe
repro.obj
C:\Temp>.\repro.exe
test failure
Expected behavior
The program should print nothing.
STL version
Additional context
This is relevant to P3737R0: std::array is a wrapper for an array!
frederick-vs-ja, YexuanXiao and FluXy
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingvNextBreaks binary compatibilityBreaks binary compatibility